Skip to content

fix: recover Android app-owned ANRs#592

Merged
thymikee merged 3 commits into
mainfrom
codex/android-anr-recovery
May 26, 2026
Merged

fix: recover Android app-owned ANRs#592
thymikee merged 3 commits into
mainfrom
codex/android-anr-recovery

Conversation

@thymikee
Copy link
Copy Markdown
Member

Summary

Recover app-owned Android ANR dialogs before guarded action commands by tapping the dialog close action, relaunching the session app, and continuing with a warning once focus returns.

Keep unrelated/system ANRs fail-fast with focused package/window context so agents get actionable feedback without closing external processes.

Closes #589

Touched files: 12. Scope stayed within Android blocking-dialog detection/recovery, daemon interaction/generic dispatch guards, and provider integration coverage.

Validation

Verified with provider integration coverage for app-owned ANR recovery and external ANR failure through the real daemon request path.

Ran pnpm format, pnpm check:quick, and pnpm check:unit. The unit bundle initially had one unrelated Android install timeout, passed in isolation, then the full unit/smoke bundle passed on rerun.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-592/

Built to branch gh-pages at 2026-05-26 08:59 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b616d164d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +237 to +240
for (const args of commands) {
const result = await runAndroidAdb(device, args, { allowFailure: true });
const parsed = parseAndroidBlockingDialogFocus(result.stdout ?? '');
if (parsed) return parsed;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Short-circuit ANR focus probe after first successful dumpsys

readAndroidBlockingDialogFocus currently iterates both dumpsys variants unless an ANR is detected, but null is the expected result in healthy sessions. That means every guarded Android action performs an unnecessary second adb shell dumpsys window probe (and this check runs both before and after commands), adding avoidable latency and ADB load on normal flows. This should stop after the first successful probe (for example when exit code is 0), and only fall back to the second command when the first probe fails or is unusable.

Useful? React with 👍 / 👎.

@thymikee thymikee force-pushed the codex/android-anr-recovery branch from 7fe79f0 to 4046d83 Compare May 26, 2026 08:59
@thymikee thymikee merged commit dcc7421 into main May 26, 2026
19 checks passed
@thymikee thymikee deleted the codex/android-anr-recovery branch May 26, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: detect Android ANR and blocking system dialogs before reporting interactions as successful

1 participant